<?php
declare(strict_types=1);
namespace Dao;
// hook dao_sys_role_auth_use.php

use Field\SysRoleAuthConst;
use Field\SysRoleConst;
use Model\SysRoleAuthModel;

class SysRoleAuthDao extends SysRoleAuthModel
{
	// hook dao_sys_role_auth_public_start.php

	protected array $add_rule	=	[];
    protected array $edit_rule	=	[];

    protected array $rule	=	[
		/*
		"mobile"=>[
			"max"=>3
			"min"=>3
			"func"=>'isMobile'
			"error"=>false,
			'message'=>'格式有误'
		],
		"username"=>[
			"max"=>3
			"min"=>3
			"func"=>'checkS'
			"error"=>false,
			'message'=>'格式有误'
		],
		*/
	];
	//数据，字段，验证规则
	/*
	function isMobile($data,$field,$val){
	
		return true;
	}
	*/
	
	// hook dao_sys_role_auth_public_end.php

    public function auto_load(): void
    {
        if($this->http_server->worker_id==0){
            $this->reload();
        }

    }
    public function reload()
    {
        // hook model_cate_reload_start.php

        $auth = $this->select([SysRoleConst::Status=>1]);
          foreach ($auth as $row){
              $this->T_Auth->set($row[SysRoleAuthConst::RoleID].','.$row[SysRoleAuthConst::Node],['Status'=>$row['Status']]);
          }

        // hook model_cate_reload_after.php
    }


    // hook dao_sys_role_auth_end.php
}
?>